<?php
$this->breadcrumbs=array(
	'Page Urls'=>array('index'),
	'Manage',
);

$this->menu=array(
//	array('label'=>'Create Page Url', 'url'=>array('/admin/page/addUrl', array('page_id'=>$pageId))),
);
?>

<?php $grid = $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'page-url-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
    'selectableRows'=>2,
//    'selectionChanged'=>"updateSelectors",
	'columns'=>array(
        array(
            'class'=>'CCheckBoxColumn',
            'value'=>'$data->id',
            'htmlOptions'=>array('width'=>'3%'),
        ),
        'url',
        array(
            'name'=>'status',
            'type'=>'raw',
            'value'=>'CHtml::link($data->statusText, array("statusUrl", "ids[]"=>$data->id, "value"=>$data->status ? 0 : 1), array("class"=>($data->status ? "active" : "")))',
            'filter'=>false,
            'cssClassExpression'=>'$data->default ? "default" : ""',
            'htmlOptions'=>array(
                'class'=>'status-column'
            )
        ),
        array(
            'name'=>'default',
            'type'=>'raw',
            'value'=>'CHtml::link("Set default", "#", array("class"=>($data->default ? "default" : "")))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'set-default-column'
            )
        ),
        array(
            'name'=>'creation_datetime',
            'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->creation_datetime))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'datetime-column'
            )
        ),
        array(
            'name'=>'last_update',
            'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->last_update))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'datetime-column'
            )
        ),
        array(
            'class'=>'CButtonColumn',
            'template'=>'{update} {delete}',
            'updateButtonUrl'=>'Yii::app()->controller->createUrl("updateUrl", array("id"=>$data->id, "page_id"=>$data->page_id))',
            'cssClassExpression'=>'$data->default ? "default" : ""',
            'deleteButtonUrl'=>'Yii::app()->controller->createUrl("deleteUrl", array("ids[]"=>$data->id))',
        ),
	),
)); 

/*if ($grid->dataProvider->ItemCount) {
    $this->menu[] = array('label' => 'Delete selected items', 'url'=>$this->createUrl('delete'), 'linkOptions' => array('onclick'=>'return multipleDelete("page-url-grid",this.href)'));
}*/
//Yii::app()->clientScript->registerScriptFile(Yii::app()->core->AssetUrl.'/scripts/gridview.js', CClientScript::POS_BEGIN);
echo CHtml::link('Create Page Url', array('addUrl', 'page_id'=>$pageId), array('class'=>'add-url'));
?>